const fs = require("fs");
let {html} = require("./html.js");
// console.log(html);
const path = "./imgName.text";
const allImfPath = "../images/";
let data = fs.readFileSync(path,{
    encoding:"utf8"
});
data = data.split(/\n/).slice(0,-1);
for(let value of data){
    console.log(value);
    let imgPath = allImfPath + value.split(",")[1];
    console.log(imgPath);
    let ptt = new RegExp(value.split(",")[1],"g");
    console.log(html.match(ptt));
    if(html.match(ptt)==null){
        try{
            fs.unlinkSync(imgPath);
        }catch{
            console.log("该图片不存在");
        }
    }else{
        html = html.replace(ptt, value.split(",")[0]);
    }
}
fs.appendFileSync("./html.html",html);